package com.cloud.springbootcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * EnableEurekaClient 客户端启动类添加服务注册
 * EnableDiscoveryClient 客户端启动类添加发现注解
 */
@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
//@LoadBalancerClients(defaultConfiguration = {MyConfig.class})
@SpringBootApplication
public class ServiceConsumerApplication {
    @Bean
//    @LoadBalanced // 负载均衡注解
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    /*
    //1. RoundRobinRule轮询策略（默认）
    @Bean public RoundRobinRule roundRobinRule() {return new RoundRobinRule();}

    //2. WeightedResponseTimeRule权重轮询策略
    @Bean public WeightedResponseTimeRule weightedResponseTimeRule() {return new WeightedResponseTimeRule();}

    //3. randomRule随机策略
    @Bean public RandomRule randomRule() {return new RandomRule();}

    //4. BestAvailableRule最少并发数策略
    @Bean public BestAvailableRule bestAvailableRule() {return new BestAvailableRule();}

    //5. RetryRule重试策略
    @Bean public RetryRule retryRule() {return new RetryRule();}

    //6. AvailabilityFilteringRule可用性敏感策略
    @Bean public AvailabilityFilteringRule availabilityFilteringRule() {return new AvailabilityFilteringRule();}

    //7. ZoneAvoidanceRule区域敏感性策略
    @Bean public ZoneAvoidanceRule zoneAvoidanceRule() {return new ZoneAvoidanceRule();}
*/
    public static void main(String[] args ) {
        //消费者
        SpringApplication.run(ServiceConsumerApplication.class);
    }
}
